package flyweight;

import java.util.HashMap;

/**
 * 工厂类负责生产
 * @author zj
 *定义一个工厂类，里面要定义一个hashmap主要根据颜色来存图形的对象，
 */
public class Factory {
	  private static final HashMap<String, Draw> hash=new HashMap<>();
	  public static Draw getCircle(String color) {
		  Draw circle = (Draw)hash.get(color);
	 
	      if(circle == null) {
	    	  circle = new CicleColor(color);
	    	 
	         hash.put(color, circle);
	         System.out.println("Creating circle of color : " + color);
	      }
	      return circle;
	   }
}
